﻿using DocumentMakingTools.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DocumentMakingTools.ViewModels
{
    internal class SettingViewModel : ViewModelBase
    {
        Page page;
        public Command ChangeDefaultOutputPathCommand  { get; set; }

        //默认输出路径
        private string outputDictionary;
        public string OutputDictionary
        { get => outputDictionary; set { SetProperty(ref outputDictionary, value); } }

        // 是否直接打开代码文档
        private bool isOpenCodeDocument;
        public bool IsOpenCodeDocument
        { get => isOpenCodeDocument; set { SetProperty(ref isOpenCodeDocument, value); } }

        public SettingViewModel(Page page)
        {
            this.page = page;

            OutputDictionary = App.AppSetting.DefaultOutputPath;
            isOpenCodeDocument = App.AppSetting.DefaultOpenCodeDocumentMode;

            ChangeDefaultOutputPathCommand = new Command(ExecuteChangeDefaultOutputPathCommand);
        }
        async void ExecuteChangeDefaultOutputPathCommand()
        {
            var newDic = await page.DisplayPromptAsync("更改默认输出路径", "请设置新的文件输出路径", "确定", "取消");
            if (!string.IsNullOrEmpty(newDic))
                OutputDictionary = newDic;
        }
    }
}
